//
//  AYMFocusDoctorViewController.m
//  QuickCure
//
//  Created by xuNick on 16/5/6.
//  Copyright © 2016年 ayumi. All rights reserved.
//

#import "AYMFocusDoctorDetailController.h"

#import "AYMDoctorConsulation.h"

@interface AYMFocusDoctorDetailController ()<DoctorConsulationDelegate>

@property (nonatomic, strong) AYMDoctorConsulation *doctorView;

@property (nonatomic, weak) UIButton *rightButton;


@end


@implementation AYMFocusDoctorDetailController

- (void)loadView {
    
    [super loadView];
    
}

-(void)viewDidLoad{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
    AYMDoctorConsulation *doctorView = [[AYMDoctorConsulation alloc] init];

    self.doctorView = doctorView;
    
    doctorView.frame = CGRectMake(0, 0, screenW, screenH);
    
    doctorView.delegate = self;
    
//    self.doctorView.model = self.model;
    [self.view addSubview:doctorView];
    
    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.rightButton = rightButton;
    [rightButton setImage:[UIImage imageNamed:@"kongxin"] forState:UIControlStateNormal];
    [rightButton setImage:[UIImage imageNamed:@"shixin"] forState:UIControlStateSelected];
    
    [rightButton addTarget:self action:@selector(clickCollectionBtn:) forControlEvents:UIControlEventTouchUpInside];
    rightButton.bounds = CGRectMake(0, 0, 30, 30);
    [rightButton sizeToFit];
    
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
    self.navigationItem.title = @"医生基本信息";
    
    
//    Log(@"%@",self.model);
}

-(void)viewDidAppear:(BOOL)animated {
    
    [super viewDidAppear:animated];
    
    self.doctorView.model = self.model;
}

# pragma mark -
# pragma mark 实现点击按钮的方法
- (void)clickCollectionBtn:(UIButton *)button {
    
//    如果已经是关注状态
    if (button.selected == YES) {
        
     
       
        
        self.rightButton.selected = NO;
//        弹出提示
        UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"您取关了这位医生" preferredStyle:UIAlertControllerStyleAlert];
        
        [self presentViewController:alertC animated:YES completion:^{
            
            [NSThread sleepForTimeInterval:1.0];
            [self dismissViewControllerAnimated:YES completion:^{
                
                if ([self.delegate respondsToSelector:@selector(focusDoctorDetailController:)]) {
                    //                    回传状态
                    [self.delegate focusDoctorDetailController:NO];
                }
                
            }];
            
        }];
    
    }else {
        
        
        UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"您关注了这位医生" preferredStyle:UIAlertControllerStyleAlert];
        
        [self presentViewController:alertC animated:YES completion:^{
            
            [NSThread sleepForTimeInterval:1.0];
            [self dismissViewControllerAnimated:YES completion:^{
                
                if ([self.delegate respondsToSelector:@selector(focusDoctorDetailController:)]) {
                    //                    回传状态
                    [self.delegate focusDoctorDetailController:YES];
                }
                
            }];

        }];
        
        self.rightButton.selected = YES;
    }
    
}

# pragma mark -
# pragma mark 实现代理方法
//点击咨询的按钮
- (void)doctorConsulation:(UIView *)doctorConsulation {
    
    UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"医生已经拒绝接诊啦" preferredStyle:UIAlertControllerStyleAlert];
    
    [self presentViewController:alertC animated:YES completion:^{
        
        [NSThread sleepForTimeInterval:1.0];
        
        [self dismissViewControllerAnimated:YES completion:^{
            
            
            
        }];
        
    }];
    
}


@end
